 <!DOCTYPE html>
 <html>
 <head>
     <meta name="viewport" content="width=device-width" />
     <meta http-equiv="x-ua-compatible" content="IE=8">
     <title>RDP</title>
     <style type="text/css">
         body {
             padding: 0;
             margin: 0;
         }
     </style>
 </head>
 <body>
     <script type="text/javascript">
   //if ("条件") { 
          //   if (window.opener.SetRDPID) { //调用打开此页的父页面中的方法
         //        window.opener.SetRDPID("123");
         //    };
 // 连接远程桌面的方法
             function RdpConnect() {
                 var userName, Pwd, server, domain, port;
                 userName = "administrator"; //用户名
                 server = "192.168.1.117"; //IP
                 port = 3389; //端口
 domain = "myDomain";  //域
                 if (!MsRdpClient.Connected) {
                     try {
                         document.getElementById("connectArea").style.display = "block"; //显示远程桌面div
                         MsRdpClient.Server = server; //设置远程桌面IP地址
                         try {
                             MsRdpClient.AdvancedSettings2.RedirectDrives = false;
                             MsRdpClient.AdvancedSettings2.RedirectPrinters = false;
                             MsRdpClient.AdvancedSettings2.RedirectPrinters = false;
                             MsRdpClient.AdvancedSettings2.RedirectClipboard = true;
                             MsRdpClient.AdvancedSettings2.RedirectSmartCards = false;
                         } catch (ex) {
                         };
 
 
                         MsRdpClient.Domain = domain;//域
                         MsRdpClient.UserName = userName;
                         //MsRdpClient.AdvancedSettings2.ClearTextpassword = Pwd; //密码
                         MsRdpClient.AdvancedSettings2.RDPPort = port; //端口
                         if (document.getElementById("ColorDepth").value == 1) {
                             ColorDepth16();
                         } else {
                             ColorDepthDefault();
                         };
                         MsRdpClient.FullScreen = 1;  //是否全屏 0否 1是
                         if (document.getElementById("Screen").value == 1) {
                             Screen1();
                         } else {
                             ScreenDefault();
                         };
                         try {
                             //如果不支持，继续下面操作
                             MsRdpClient.AdvancedSettings7.EnableCredSspSupport = true;
                             MsRdpClient.AdvancedSettings5.AuthenticationLevel = 2;
                         } catch (ex) {
                         } finally {                
                             MsRdpClient.Connect();  //连接远程桌面
                         }
                     } catch (ex) {
                         alert("发生错误：" + ex.message + "请尝试刷新页面重新连接。");
                     };
                 } else {
                     alert("已连接！");
                 };
             };
             //var logoff = false; //存储是否正常注销
             //全屏
             function FullScreen() {
                 if (MsRdpClient.Connected) {
                     MsRdpClient.FullScreen = 1;
                 };
             };
             //1024*768
             function ScreenDefault() {
                 MsRdpClient.Width = 1024; //设置远程桌面 显示区域的宽和高
                 MsRdpClient.Height = 768;
                 MsRdpClient.DesktopWidth = 1024;  //设置 远程桌面的宽和高
                 MsRdpClient.DesktopHeight = 768;
             };
             //800*600
             function Screen1() {
                 MsRdpClient.Width = 800; //设置远程桌面 显示区域的宽和高
                 MsRdpClient.Height = 600;
                 MsRdpClient.DesktopWidth = 800;  //设置 远程桌面的宽和高
                 MsRdpClient.DesktopHeight = 600;
             };
             //色彩度，默认32位
             function ColorDepthDefault() {
                 MsRdpClient.ColorDepth = 32;
             };
             //色彩度16位
             function ColorDepth16() {
                 MsRdpClient.ColorDepth = 16;
             };
             function reSet() {
                 document.getElementById("Screen").selectedIndex = 1;
                 document.getElementById("ColorDepth").selectedIndex = 1;
             };
 
 //关闭当前页面
         function closeWindow() {
             window.opener = null;
             window.open("", "_self");
             window.close();
         };
 </script>
     <!--远程桌面参数设置start-->
     <div style="display:none"><fieldset>
         分辨率：<select id="Screen">
             <option value="1">800*600</option>
             <option value="2" selected="selected">1024*768</option>
         </select>
         色彩度：<select id="ColorDepth">
             <option value="1">16位</option>
             <option value="2" selected="selected">32位</option>
         </select>
         <input type="button" value="重置" onclick="reSet()" />
     </fieldset>
     <input type="button" id="connectbutton" value="连接" onclick="RdpConnect();" /></div>
      <!--远程桌面参数设置end-->
     <input type="button" class="btn btn-warning" style="width:80px;" value="全屏" onclick="FullScreen()" />
     <div id="connectArea" style="display: none;">
         <table>
             <tr>
                 <td>
                     <object id="MsRdpClient"
                         classid="CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850"
                         codebase="msrdp.cab#version=5,2,3790,0" width="1024px" height="768px">
                     </object>
                 </td>
             </tr>
             <script type="text/javascript">
                 /*function MsRdpClient::OnDisconnected(disconnectCode) {
                     document.getElementById("connectArea").style.display = "none";
                     //正常注销，代码为2
                     //if (disconnectCode != 2) {
                     //    if (logoff == false) {
                     //        alert("计算机处于断开状态，请根据提示完成后续步骤：\r\n(1)如果您操作已完成，请刷新页面重新连接并注销；\r\n(2)如果仍需操作，请刷新页面后继续，完毕后请注销。\r\n谢谢您的配合！");
                     //    } else {
                     //        alert("计算机已注销，如需使用，请刷新此页面。");
                     //    }
                     //} else {
                     //    logoff = true; //记录注销状态
                     //    //关闭当前页面
                     //};
                     closeWindow();
                 }*/
             </script>
         </table>
     </div>
 </body>
 </html>